﻿@model PagedList.IPagedList<AppStore.Domain.Entities.Application>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            name
        </th>
        <th>
            description
        </th>
        <th>
            price
        </th>
        <th>
            icon
        </th>
        <th>
            counter
        </th>
        <th>
            categoryId
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.description)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.price)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.icon)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.counter)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.categoryId)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { applicationId=item.applicationId }) |
                @Html.ActionLink("Details", "Details", new { applicationId=item.applicationId }) |
                @Html.ActionLink("Delete", "Delete", new { applicationId=item.applicationId })
            </td>
        </tr>
    }

</table>
<div style="overflow: hidden; text-align: center;">
    Strona: @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    z @Model.PageCount
    
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<","Index","ApplicationManager",new { page = 1})
        @Html.Raw(" ")
        @Html.ActionLink("Poprzednia","Index","ApplicationManager",new { page = Model.PageNumber - 1})
     }
    else
    {
         @Html.Raw("<<")
         @Html.Raw(" ")
         @Html.Raw("Poprzednia")
    } 
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Następna","Index","ApplicationManager",new { page = Model.PageNumber+1})
        @Html.Raw(" ")
        @Html.ActionLink(">>","Index","ApplicationManager",new { page = Model.PageCount})
    }
    else
    {
         @Html.Raw("Następna")
         @Html.Raw(" ")
         @Html.Raw(">>")
    }
</div>
